package guitforl.wrappers

import guitforl.traits.UpdateableWidget
import javax.swing.JLabel
import java.awt.{Dimension, Font}
import guitforl.data.readers.DataReader

/**
 * Created by IntelliJ IDEA.
 * User: artem
 * Date: Jun 27, 2010
 * Time: 12:04:10 AM
 * To change this template use File | Settings | File Templates.
 */
class LabelWrapper(val widgetName:String, private val defaultValue: String, private val dataSource: Seq[DataReader]) extends JLabel with UpdateableWidget{
	setText(defaultValue)
	setFont(new Font("Calibri", 25, 15))

	def update = {
		setText(buildLabelText)
	}

	private def buildLabelText = {
		val textBuilder = new StringBuilder
		dataSource.foreach(dataSource => textBuilder.append(dataSource.getAllAsString))
		textBuilder.toString
	}
}